#define _CRT_SECURE_NO_WARNINGS 1

//https://www.nowcoder.com/practice/4436c93e568c48f6b28ff436173b997f?tpId=13&tqId=2273153&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking

//static int arr[100010] = { 0 };
//int* printNumbers(int n, int* returnSize) {
//    // write code here
//    int i = 0;
//    for (i = 1; i < pow(10, n); i++)
//    {
//        arr[i - 1] = i;
//    }
//    *returnSize = --i;
//    return arr;
//}


//https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded?tpId=37&&tqId=21296&rp=1&ru=/ta/huawei&qru=/ta/huawei/question-ranking
//
#include <stdio.h>

int main()
{
    int month_day[12] = { 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
    int y = 0;
    int m = 0;
    int d = 0;
    int r = 0;
    scanf("%d %d %d", &y, &m, &d);
    if (m >= 2)
    {
        r = month_day[m - 2] + d;
    }
    else
    {
        r = d;
    }
    if (m > 2)
    {
        if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0))
        {
            r++;
        }
    }
    printf("%d", r);
    return 0;
}